#include "on_property_get.h"
#include "spec.h"
#include "mi_iid_define.h"
#include "S_1_DeviceInformation_doGet.h"
#include "S_2_AirConditioner_doGet.h"
#include "S_3_FanControl_doGet.h"
#include "S_4_Environment_doGet.h"
#include "S_5_Alarm_doGet.h"
#include "S_20_PowerConsumption_doGet.h"
#include "S_25_AirConditionerDevMode_doGet.h"
#include "S_38_Filter_doGet.h"
#include "S_8_Electricity_doGet.h"
#include "S_9_Maintenance_doGet.h"
#include "S_10_Enhance_doGet.h"
#include "S_11_IotLinkage_doGet.h"
#include "S_12_MachineState_doGet.h"
#include "S_13_FlagBit_doGet.h"
#include "S_14_AirFresh_doGet.h"
#include "S_16_SingleSmartScene_doGet.h"
#include "S_23_FavoriteTypeData_doGet.h"
#include "S_24_Filter_doGet.h"
#include "S_27_AiContrrol_doGet.h"
#include "S_29_ProductConfig_doGet.h"
#include "S_36_IndicatorLight_doGet.h"
#include "S_37_PanelSerVice_doGet.h"
#include "S_41_DetectNobodySaveEnergy_doGet.h"
#include "S_42_AirFreshFanControl_doGet.h"
#include "S_43_AircFreshLinkage_doGet.h"

#if 1

void on_property_get(property_operation_t *o)
{
    LOG_INFO("on_property_get\r\n");
	LOG_INFO("siid: %d\n", o->siid);
	LOG_INFO("piid: %d\n", o->piid);

    switch (o->siid)
    {
		case SIID_1_DeviceInformation:
			S_1_DeviceInformation_doGet(o);
		break;

		case SIID_2_AirConditioner:
			S_2_AirConditioner_doGet(o);
		break;
		
		case SIID_3_FanControl:
			S_3_FanControl_doGet(o);
		break;
		
		case SIID_4_Environment:
			S_4_Environment_doGet(o);
		break;
		
		case SIID_5_Alarm:
			S_5_Alarm_doGet(o);
		break;
		
		case SIID_8_Electricity:
			S_8_Electricity_doGet(o);
		break;
		
		case SIID_9_Maintenance:
			S_9_Maintenance_doGet(o);
		break;
		
		case SIID_10_Enhance:
			S_10_Enhance_doGet(o);
		break;

		case SIID_11_IotLinkage:
			S_11_IotLinkage_doGet(o);
		break;
		
		case SIID_12_MachineState:
			S_12_MachineState_doGet(o);
		break;
		
		case SIID_13_FlagBit:
			S_13_FlagBit_doGet(o);
		break;
		
		case SIID_14_AirFresh:
			S_14_AirFresh_doGet(o);
		break;
		
		case SIID_16_SingleSmartScene:
			S_16_SingleSmartScene_doGet(o);
		break;
		
		case SIID_20_PowerConsumption:
			S_20_PowerConsumption_doGet(o);
		break;
		
		case SIID_23_FavoriteTypeData:
			S_23_FavoriteTypeData_doGet(o);
		break;
		
		case SIID_24_Filter:
			S_24_Filter_doGet(o);
		break;
		
		case SIID_25_AirConditionerDevMode:
			S_25_AirConditionerDevMode_doGet(o);
		break;
		
		case SIID_27_AiContrrol:
			S_27_AiContrrol_doGet(o);
		break;
		
		case SIID_29_ProductConfig:
			S_29_ProductConfig_doGet(o);
		break;
		
		case SIID_36_IndicatorLight:
			S_36_IndicatorLight_doGet(o);
		break;
		
		case SIID_37_PanelSerVice:
			S_37_PanelSerVice_doGet(o);
		break;
		
		case SIID_38_Filter:
			S_38_Filter_doGet(o);
		break;
		
		case SIID_41_DetectNobodySaveEnergy:
			S_41_DetectNobodySaveEnergy_doGet(o);
		break;
		
		case SIID_42_AIRFRESHFANCONTROL:
			S_42_AirFreshFanControl_doGet(o);
		break;

		case SIID_43_AIRCFRESHLINKAGE:
			S_43_AircFreshLinkage_doGet(o);
		break;		
        default:
		o->code = OPERATION_ERROR_VALUE;
		break;
    }
}

#else

typedef void(*proto_proc_fuc)(property_operation_t* frame);

typedef struct {
    unsigned int Siid;
    proto_proc_fuc func;
} PropertyGet;


PropertyGet g_PropertyGet[] = {
    { SIID_1_DeviceInformation,   		S_1_DeviceInformation_doGet},
	{ SIID_2_AirConditioner,   			S_2_AirConditioner_doGet},
	{ SIID_3_FanControl,   				S_3_FanControl_doGet},
	{ SIID_4_Environment,   			S_4_Environment_doGet},
};

#define MIIO_ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0]))
void on_property_get(property_operation_t *o)
{
    LOG_INFO("on_property_get\r\n");
	LOG_INFO("siid: %d\n", o->siid);
	LOG_INFO("piid: %d\n", o->piid);

    unsigned int i = 0;
    for (i = 0; i < MIIO_ARRAY_COUNT(g_PropertyGet); i++)
    {
        if (o->siid == g_PropertyGet[i].Siid) 
		{
            if (g_PropertyGet[i].func != NULL) 
			{
                g_PropertyGet[i].func(o);
				break;
            }
        }
    }
	if(i == MIIO_ARRAY_COUNT(g_PropertyGet))
		o->code = OPERATION_ERROR_VALUE;
}

#endif


